<template>
  <div class="main-box">
    <el-button
      type="primary"
      icon="el-icon-plus"
      style="margin-bottom: 15px"
      @click="handelAddSoft"
    >
      添加
    </el-button>
    <BaseTable :request="request" ref="baseTable">
      <el-table-column label="软件名称" prop="title" />
      <el-table-column label="证书编号" prop="code" />
      <el-table-column label="登记号" prop="reg_code" />
      <el-table-column label="发证日期" prop="grant_time" />
      <el-table-column :label="$t('创建时间')" prop="create_time" />
      <el-table-column
        :label="$t('操作')"
        width="100px"
        align="right"
        fixed="right"
      >
        <template slot-scope="scope">
          <EditBtn @click="handelAddSoft(scope.row)" />

          <DelBtn @success="handleDelete(scope.row)" />
        </template>
      </el-table-column>
    </BaseTable>
  </div>
</template>

<script>
import softApi from '@/api/soft'
export default {
  data() {
    return {
      request: softApi.softList
    }
  },

  methods: {
    handelAddSoft(row = {}) {
      this.$router.push({
        name: 'editSoft',
        query: {
          id: row.id
        }
      })
    },
    async handleDelete(row) {
      const res = await softApi.deleteSoft({ id: row.id })
      if (res.code == 0) {
        this.$refs.baseTable.getList('search')
        this.$message.success(res.msg)
      }
    }
  }
}
</script>
